FROM centos:centos7.9.2009
USER root

# modify date zone
#RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
ENV TZ=Asiz/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# update yum repo
RUN mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo --progress
RUN curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo --progress
RUN yum clean all
RUN yum makecache
RUN yum -y update

WORKDIR /root
RUN mkdir Softwares
RUN mkdir Downloads

ADD OpenJDK8U-jdk_x64_linux_8u342b07.tar.gz /root/Softwares
ADD test-spring-boot.jar /root/Downloads/
ADD application.yml /root/Downloads
ADD ESAPI.properties /root/Downloads
ADD esapi-java-logging.properties /root/Downloads
ADD README.md /root/Downloads
ADD validation.properties /root/Downloads

RUN echo "export JAVA_HOME=/root/Softwares/openjdk-8u342-b07" >> /etc/profile
RUN echo "export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar" >> /etc/profile
RUN echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> /etc/profile
RUN echo "export JAVA_OPTS=\"-server -Xms128m -Xmx3g -Xss256k -Djava.awt.headless=true -Dfile.encoding=utf-8\"" >> /etc/profile

COPY init.sql /root/Softwares
COPY initdb.sh /root/Softwares
RUN yum install -y mariadb mariadb-server mariadb-libs mariadb-devel
RUN systemctl enable mariadb

WORKDIR /root/Softwares
ENTRYPOINT /usr/sbin/init